<!DOCTYPE html>
<html>
<head th:include="common/header_css::header('霸王餐小程序后台管理-商品信息','%mfile%datepicker%summernote')"></head>
<!--<head th:include="common/header_css::header('霸王餐小程序后台管理-商户管理-商户配置')"></head>-->
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div th:replace="common/toolbar::toolbar('商家配置管理')"></div>
        <div th:replace="common/search::search('%add')"></div>
        <!-- End Panel Basic -->
    </div>

    <!--添加MerchantConfig模态框-->
    <div id="modal-add-form" class="modal fade" aria-hidden="true">
        <div class="modal-dialog" style="width: 800px;">
            <div class="modal-content">
                <div class="modal-body">
                    <div class="row">
                        <h3 class="m-t-none m-b">商家配置添加</h3>
                        <div class="col-sm-12">
                            <div class="ibox float-e-margins">
                                <div class="ibox-content">
                                    <form id="aform" method="post" class="form-horizontal" action="add" onsubmit="return checkAdd()">
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">支持分享 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <input type="checkbox" class="js-switch" name="isShare"
                                                               value="-1">
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">支持搜索 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <input type="checkbox" class="js-switch" name="isSearch"
                                                               value="-1">
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">支持会员 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <input type="checkbox" class="js-switch" name="isMember"
                                                               value="-1">
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">支持积分 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <input type="checkbox" class="js-switch" name="isJifen"
                                                               value="-1">
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">支持优惠券 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <input type="checkbox" class="js-switch" name="isCoupon"
                                                               value="-1">
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">支持模板消息 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <input type="checkbox" class="js-switch" name="isTmplmsg"
                                                               value="-1">
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">是否多门店 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <input type="checkbox" class="js-switch" name="isMultishop"
                                                               value="-1">
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">是否支持会员卡现金业务 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <input type="checkbox" class="js-switch" name="isEcashCard"
                                                               value="-1">
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">支持分类 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <input type="checkbox" class="js-switch" name="showCategory" value="-1">
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">目录类别 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <select class="form-control" name="categoryType">
                                                            <option value="1">竖状</option>
                                                            <option value="2">横状</option>
                                                        </select>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">banner类型 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <select class="form-control" name="bannerType">
                                                            <option value="0">无</option>
                                                            <option value="1">短banner</option>
                                                            <option value="2">大banner</option>
                                                        </select>
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">列表项类型 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <select class="form-control" name="listType">
                                                            <option value="1">一行1列</option>
                                                            <option value="2">一行2列</option>
                                                        </select>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">目录层级类别 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <select class="form-control" name="categoryLevelType">
                                                            <option value="1">1级(无子品牌)</option>
                                                            <option value="2">2级(含二级品牌)</option>
                                                        </select>
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">多少积分兑换一元 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <input class="form-control" name="jifenRate"
                                                               required
                                                               type="number"/>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">最大消费积分 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <input class="form-control" name="maxJifen"
                                                               required
                                                               type="number"/>
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">默认会员折扣 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <input class="form-control" name="memberDiscountRate"
                                                               required
                                                               type="number"/>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">最低提现额度 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <input class="form-control" name="minTixian"
                                                               required
                                                               type="number"/>
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">提现方式 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <select class="form-control" name="tixianType">
                                                            <option value="1">微信</option>
                                                            <option value="2">支付宝</option>
                                                        </select>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">关于我们模式 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <select class="form-control" name="aboutType">
                                                            <option value="0">基本配置模式</option>
                                                            <option value="1">自编辑模式</option>
                                                            <option value="2">官网地址</option>
                                                        </select>
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">官网网站地址</label>
                                                    <div class="col-sm-8">
                                                        <input class="form-control" name="website"
                                                               type="url" maxlength="200"/>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="row">
                                        </div>
                                        <div class="row">
                                            <div class="col-md-12">
                                                <div class="form-group">
                                                    <label class="col-sm-2 control-label">关于商家介绍</label>
                                                    <div class="col-sm-10">
                                                        <div id="snaboutus" class="summernote"></div>
                                                        <input type="hidden" id="aboutus" name="aboutus"/>

                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <div class="col-sm-4 col-sm-offset-2">
                                                <button class="btn btn-primary" type="submit">保存内容</button>
                                                <button data-toggle="modal" type="button" class="btn btn-white"
                                                        href="#modal-add-form">取消
                                                </button>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!--修改MerchantConfig模态框-->
    <div id="modal-form" class="modal fade" aria-hidden="true">
        <div class="modal-dialog" style="width: 800px;">
            <div class="modal-content">
                <div class="modal-body">
                    <div class="row">
                        <h3 class="m-t-none m-b">商家配置修改</h3>
                        <div class="col-sm-12">
                            <div class="ibox float-e-margins">
                                <div class="ibox-content">
                                    <form id="mform" method="post" class="form-horizontal" action="modify" enctype="application/x-www-form-urlencoded" onsubmit="return checkModify()">
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">支持分享 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <input type="checkbox" id="isShare" name="isShare" value="-1">
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">支持搜索 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <input type="checkbox" id="isSearch" name="isSearch" value="-1">
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">支持会员 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <input type="checkbox" id="isMember" name="isMember" value="-1">
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">支持积分 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <input type="checkbox" id="isJifen" name="isJifen" value="-1">
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">支持优惠券 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <input type="checkbox" id="isCoupon" name="isCoupon" value="-1">
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">支持模板消息 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <input type="checkbox" id="isTmplmsg" name="isTmplmsg"
                                                               value="-1">
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">是否多门店 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <input type="checkbox" id="isMultishop" name="isMultishop"
                                                               value="-1">
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">是否支持会员卡现金业务*
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <input type="checkbox" id="isEcashCard" name="isEcashCard"
                                                               value="-1">
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">支持分类*
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <input type="checkbox" id="showCategory" name="showCategory" value="-1">
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">目录类别 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <select class="form-control" name="categoryType"
                                                                id="categoryType">
                                                            <option value="1">竖状</option>
                                                            <option value="2">横状</option>
                                                        </select>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">banner类型*
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <select class="form-control" name="bannerType" id="bannerType">
                                                            <option value="0">无</option>
                                                            <option value="1">短banner</option>
                                                            <option value="2">大banner</option>
                                                        </select>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">列表项类型*
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <select class="form-control" name="listType" id="listType">
                                                            <option value="1">一行1列</option>
                                                            <option value="2">一行2列</option>
                                                        </select>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">目录层级类别*
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <select class="form-control" name="categoryLevelType"
                                                                id="categoryLevelType">
                                                            <option value="1">1级(无子品牌)</option>
                                                            <option value="2">2级(含二级品牌)</option>
                                                        </select>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">多少积分兑换一元*
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <input class="form-control" id="jifenRate" name="jifenRate"
                                                               required
                                                               type="number"/>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">最大消费积分*
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <input class="form-control" id="maxJifen" name="maxJifen"
                                                               required
                                                               type="number"/>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">默认会员折扣 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <input class="form-control" id="memberDiscountRate"
                                                               name="memberDiscountRate"
                                                               required
                                                               type="number"/>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">最低提现额度 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <input class="form-control" id="minTixian" name="minTixian"
                                                               required
                                                               type="number"/>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">提现方式 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <select class="form-control" name="tixianType" id="tixianType">
                                                            <option value="1">微信</option>
                                                            <option value="2">支付宝</option>
                                                        </select>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">关于我们模式 *
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <select class="form-control" name="aboutType" id="aboutType">
                                                            <option value="0">基本配置模式</option>
                                                            <option value="1">自编辑模式</option>
                                                            <option value="2">官网地址</option>
                                                        </select>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">官网网站地址</label>
                                                    <div class="col-sm-8">
                                                        <input class="form-control" id="website" name="website"
                                                               type="url" maxlength="200"/>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                        </div>
                                        <div class="row">
                                            <div class="col-md-12">
                                                <div class="form-group">
                                                    <label class="col-sm-2 control-label">关于商家介绍</label>
                                                    <div class="col-sm-10">
                                                        <div id="snaboutus2" class="summernote"></div>
                                                        <input type="hidden" id="aboutus2" name="aboutus"
                                                        />
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <div class="col-sm-4 col-sm-offset-2">
                                                <button class="btn btn-primary" type="submit">保存内容</button>
                                                <button data-toggle="modal" type="button" class="btn btn-white"
                                                        href="#modal-form">取消
                                                </button>
                                            </div>
                                        </div>
                                        <input id="id" name="id" type="hidden" value=""/>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div th:include="common/footer_js::footer"></div>
    <script>

        //图片上传
        function sendFile(file, editor, $editable) {

            var filename = false;
            try {
                filename = file['name'];
            } catch (e) {
                filename = false;
            }
            if (!filename) {
                $(".note-alarm").remove();
            }
            //以上防止在图片在编辑器内拖拽引发第二次上传导致的提示错误
            data = new FormData();
            data.append("mfile", file);
            data.append("key", filename); //唯一性参数

            $.ajax({
                data: data,
                type: "POST",
                url: "/upload/file?type=sn_MerchantConfig",
                cache: false,
                contentType: false,
                processData: false,
                success: function (e) {
                    console.log(e)
                    if (e && e.code != 0) {
                        swal({title: "上传失败", text: "", type: "error"})
                        return;
                    } else {
                        swal({title: "上传成功", text: "", type: "success"})
                    }
                    editor.insertImage($editable, e.data);
                    setTimeout(function () {
                        $(".note-alarm").remove();
                    }, 5000);
                },
                error: function () {
                    swal({title: "上传失败", text: "", type: "error"})
                    return;
                }
            });
        }

        $(document).ready(function () {
            $(".summernote").summernote({
                lang: "zh-CN",
                width: 535,
                height: 260,
                dialogsInBody: true,
                onImageUpload: function (files, editor, $editable) {
                    sendFile(files[0], editor, $editable);
                }
            })
        });
    </script>
    <script src="/js/admin/merchantconfig.js"></script>
</body>
</html>
